declare const array: string[];

array.sort((a, b) => a.length - b.length);
array.sort((a, b) => a.localeCompare(b));

const array: any[];
const userDefinedType: { sort(): void };

array.sort((a, b) => a - b);
array.sort((a, b) => a.localeCompare(b));

userDefinedType.sort();

//github
const one = '1';
const two = '2';
const three = '3';
[one, two, three].sort();

function f(a: any[]) {
  a.sort(undefined);
}

function f(a: any[]) {
  a.sort((a, b) => a - b);
}

function f(a: Array<string>) {
  a.sort(undefined);
}

function f(a: Array<number>) {
  a.sort((a, b) => a - b);
}

function f(a: { sort(): void }) {
  a.sort();
}

class A {
  sort(): void {}
}
function f(a: A) {
  a.sort();
}

interface A {
  sort(): void;
}
function f(a: A) {
  a.sort();
}

interface A {
  sort(): void;
}
function f<T extends A>(a: T) {
  a.sort();
}

function f(a: any) {
  a.sort();
}

function f(a: any[]) {
  a?.sort((a, b) => a - b);
}

function f(a: number[]) {
  a.toSorted((a, b) => a - b);
}

['foo', 'bar', 'baz'].sort();

function getString() {
  return 'foo';
}
[getString(), getString()].sort();

const foo = 'foo';
const bar = 'bar';
const baz = 'baz';
[foo, bar, baz].sort();

declare const x: string[];
x.sort();

const one = '1';
const two = '2';
const three = '3';
[one, two, three].sort();